import { getOrderById } from '@/api/order'
const state = {
  orderList: [],
  order: {},
  orderDetail: {},
  orderDetailList: [],
  end: ''
}
const getters = {
}
const mutations = {
  setOrderList (state, orderList) {
    state.orderList = orderList
  },
  setOrder (state, order) {
    console.log(order)
    state.order = order
  },
  setOrderDetail (state, orderDetail) {
    state.orderDetail = orderDetail
  },
  setOrderDetailList (state, orderDetailList) {
    state.orderDetailList = orderDetailList
  },
  setEnd (state, end) {
    state.end = end
  }
}
const actions = {
  SET_ORDER ({ commit }, order) {
    commit('setOrder', order)
  },
  async getOrderById ({ commit }, id) {
    const order = await getOrderById(id)
    commit('setOrder', order.data)
  }
}
export default {
  namespaced: true,
  state,
  getters,
  mutations,
  actions
}
